package com.itheima.jobs;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.service.OrderSettingService;

import java.text.SimpleDateFormat;
import java.util.Date;

public class ClearOrderSettingJob {

    @Reference  //这个地方是远程调用，当前job模块没有配置dubbo！！！
    private OrderSettingService orderSettingService;

    public void clearOrderSetting(){
        //获取当前日期2020-03-11
        String format = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
        try {
            orderSettingService.clear(format);
            System.out.println("自定义任务执行，清理过期数据" + format);
        }catch(Exception e){
            System.out.println("自定义任务执行，清理过期数据失败");
        }

    }

}